/*
 * @Author : Genustin
 * @Date   : 2012-05-30
 * 校门外的树
 * 有一排树，修地铁要挖去若干棵，告知挖树的区域
 * 求解剩余的树的数目
 */
#include <iostream>
using namespace std;

int main()
{
	int L, M;
	int start, end;
	bool* trees;
	int count=0;
	cin >> L >> M;
	trees = new bool[L+1];
	for (int i = 0; i <= L; ++i)
	{
		trees[i] = true;
	}

	for (int i = 0; i < M; ++i)
	{
		cin >> start >> end;
		if (start > end) {
			// 排除不正常的输入
			continue;
		} else if (start >= 0 and end <= L) { 
			// 
			for (int j = start; j <= end; ++j)
			{
				if (trees[j] == true)
				{
					trees[j] = false;
					++count;
				}
			}
		}
	}
	cout << L+1-count << endl;
	delete trees;
	return 0;
}